package com.apes.autoparts.product.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 类描述：原厂标准商品
 *
 * @ClassName originalProduct
 * @Description 描述
 * @Author wushilong
 * @Date 2022/10/8 14:00
 * @Version 1.0
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = OriginalProduct.CONST_TABLE_NAME,indexes = {
        @Index(name = "idx_original_product_oeAndEPC", columnList = "oe_mark,epc_version", unique = true)})
public class OriginalProduct extends BaseModel {
    public static final String CONST_TABLE_NAME = "auto_original_product";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "原厂标准商品")
    @Comment("编码")
    private String id;

    @Column(name = "name", nullable = false, length = 100)
    @Comment("配件名称")
    private String name;

    @Column(name = "oe_mark", nullable = false, length = 100)
    @Comment("OE号")
    private String oeMark;//原厂件号

    @Column(name = "epc_version", nullable = false, length = 100)
    @Comment("EPC版本号")
    private String epcVersion;//多种车型或车品牌会共用一份EPC，同版本内的OE号不会重复

}
